package org.eproject.core.well.frontcontcoller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eproject.core.well.command.ICommand;
import org.eproject.core.well.exception.CommandException;
import org.eproject.core.well.viewhelp.Helper;

public class Frontcontcoller extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Helper v = new Helper(request, response);
		ICommand c;
		String page = null;
		try {
			c = v.findCommand();
			page = c.execute(v);
		} catch (CommandException e) {
			e.printStackTrace();
		}
		request.getRequestDispatcher(page).forward(request, response);
		return;
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		this.doGet(req, resp);
	}

}
